[PB] PartkeyGetRecord2.0

支持版本:3.50.0

简介

根据主键索引获取相关记录,主键索引在表定义proto文件中定义。主键索引是基于主键字段设计的一种索引。接口同时支持过滤字段返回,通过Select参数指定要返回的字段名;并可控制返回的记录条数,通过参数Limit指定。

POST http://{Tcaplus_REST_URL}

请求语法

Http请求

#国内idc&dev&其他自建环境:联系dba分配restproxy进程后由dba提供相应Tcaplus_REST_URL
#腾讯云控制台 RESTful Endpoint, ip:80, 端口默认80
http://172.17.0.22
#TcaplusDB本地docker版 RESTful Endpoint, ip:31001, 端口默认31001
http://9.135.8.93:31001

Http请求头参数

名称 是否必填 限制条件 说明
x-tcaplus-target Tcaplus.GetRecordByPartKey
x-tcaplus-version Tcaplus3.50.0
x-tcaplus-app-id 对应业务id编号(aka,集群接入id)
x-tcaplus-zone-id 对应zone编号(aka,表格组id)
x-tcaplus-protocol-version 对应protocol版本号,默认2.0
x-tcaplus-table-name 对应表名
x-tcaplus-pwd-md5 业务密码(aka,集群访问密码),传入计算后的md5值
x-tcaplus-idl-type protobuf
x-tcaplus-result-flag 0:操作成功后不返回数据1:操作成功后返回和请求一致的数据2:操作成功后返回本次update操作后的数据3:操作成功后返回tcapsvr端操作前的数据
x-tcaplus-data-version-check 1:检测记录版本号,只有当该版本号与服务器端的版本号相同时,该版本号才会自增2:不检测记录版本号,强制把客户端的记录版本号写入到服务器中3:不检测记录版本号,将服务器端的版本号自增
x-tcaplus-data-version 具体的version值

示例:

x-tcaplus-target:Tcaplus.GetRecordByPartKey
x-tcaplus-app-id:3
x-tcaplus-zone-id:1
x-tcaplus-protocol-version:2.0
x-tcaplus-table-name:game_players
x-tcaplus-pwd-md5:4e81984efccfb4982333aeb1ff7968d5
x-tcaplus-result-flag:2
x-tcaplus-version:Tcaplus3.50.0
x-tcaplus-data-version-check: 3
x-tcaplus-idl-type:protobuf

Data

使用json格式表示记录相关信息。参数说明:

  • Select: 可选,过滤返回的字段,指定字段名,不能为主键字段名。
  • Limit: 可选,限制每次请求返回的记录条数
  • Offset: 可选,查询记录起始编号
  • Record: 必须,指定主键索引字段

示例:

{
    "Limit": 1,
    "Record": {
        "player_id": 5,
        "player_name": "5"
    },
    "Select": ["game_server_id", "is_online", "pay"]
}

完整请求示例

curl -i -XPOST -H 'x-tcaplus-target: Tcaplus.GetRecordByPartKey' -H 'x-tcaplus-app-id: 70' -H 'x-tcaplus-zone-id: 1' -H 'x-tcaplus-protocol-version: 2.0' -H 'x-tcaplus-table-name: game_players' -H 'x-tcaplus-pwd-md5: 0972ad76decf4d11a69e2e0d9af335da' -H 'x-tcaplus-result-flag: 2' -H 'x-tcaplus-version: Tcaplus3.50.0' -H 'x-tcaplus-data-version-check: 3' -H 'x-tcaplus-idl-type: protobuf' http://172.17.32.17 -d '{
    "Record": {
        "player_id":5,
        "player_name":"5"
    },
    "Select":["game_server_id", "is_online", "pay"]
}'

返回语法

返回参数说明

参数名 说明
ErrorCode 返回码
ErrorMsg 返回信息
RecordVersion 记录版本号
MultiRecords json格式,成功的记录返回数据数组,数组元素为Record记录数据
TotalNum 本地索引对应的记录总数

返回示例

成功返回示例

{
    "ErrorCode": 0,
    "ErrorMsg": "Succeed",
    "MultiRecords": [{
        "RecordVersion": 1,
        "Record": {
            "game_server_id": 55,
            "is_online": false,
            "pay": {
                "pay_id": 55,
                "amount": 55,
                "method": 55
            },
            "player_email": "55",
            "player_id": 5,
            "player_name": "5"
        }
    }, {
        "RecordVersion": 1,
        "Record": {
            "game_server_id": 5,
            "is_online": false,
            "pay": {
                "pay_id": 5,
                "amount": 5,
                "method": 5
            },
            "player_email": "5",
            "player_id": 5,
            "player_name": "5"
        }
    }],
    "TotalNum": 2
}

失败返回示例

{
    "ErrorCode": 261,
    "ErrorMsg": "Record does not exist"
}

错误码

参考 常见错误码

其它参考文档

[PB Generic表][C++ SDK]查询本地索引接口说明

[PB Generic表][Go SDK]查询本地索引接口说明

results matching ""

    No results matching ""